<?php $this->_extends('_layouts/main_layout'); ?>
<?php $this->_block('title'); ?>
	Advertiser Data
<?php $this->_endblock(); ?>

<?php $this->_block('contents'); ?>

<div id="content" class="box">
	<h1>Advertisers</h1>
	<div id="menu" class="box">
		<ul class="box">
			<li><a href="<?php echo url('advertiserdata/add');?>"><span>Add</span></a></li>
		</ul>
	</div>
		<?php if (isset($infos)) 
				{
					foreach ($infos as $info)
					{
		?>
				<p class="msg info"><?php echo $info;?></p>
		<?php		}
				}
		?>
	<fieldset>
		<legend>Search</legend>
		<form action="<?echo url('advertiserdata/index'); ?>" method="get">
			<div class="row" id="search">
				<p>
					<label>Advertiser Name: </label>
						<?php
							 echo Util::buildDropDownList(
							 	array('id'=>'advertiser', 'name'=>'advertiser_id'),
							 	$advertisers,
							 	isset($advertiser_id) ? $advertiser_id : false,
							 	array('k'=>'', 'l'=>'--All--')
							 );
						?>
				</p>
				<p>
					<label>Site: </label>
						<?php
							 echo Util::buildDropDownList(
							 	array('id'=>'site', 'name'=>'site_id'),
							 	$sites,
							 	isset($site_id) ? $site_id : false,
							 	array('k'=>'', 'l'=>'--All--')
							 );
						?>
				</p>
				<p>
					<label>Date Start: </label><input type="text" name="date_start" class="date" value="<?php echo isset($date_start) ? $date_start : ''; ?>"/>
				</p>
				<p>
					<label>Date End: </label><input type="text" name="date_end" class="date" value="<?php echo isset($date_end) ? $date_end : ''; ?>"/>
				</p>
				<p>
					<input type="submit" class="formbutton" value="Search" />
				</p>
			</div>
		</form>
	</fieldset>
	<fieldset>
		<legend>Advertisers</legend>
		<table class="full-size">
			<thead>
				<tr>
					<th>Date</th>
					<th>Site Name</th>
					<th>Advertiser Name</th>
					<th>Click</th>
					<th>Revenue</th>
					<th></th>
				</tr>
			</thead>
			<tbody>
				<?php 
					if ($advertiserData && count($advertiserData) > 0):
						foreach($advertiserData as $item): 
				?>
					<tr>
						<td><?php echo $item['data_time']; ?></td>
						<td><?php echo $sites[$item['site_id']]; ?></td>
						<td><?php echo $advertisers[$item['advertiser_id']]; ?></td>
						<td><?php echo $item['click']; ?></td>
						<td><?php echo $item['revenue']; ?></td>
						<td>
							<a href="<?php echo url('advertiserdata/edit', array('id'=>$item['id']));?>">Edit</a>
							<a href="<?php echo url('advertiserdata/delete', array('id'=>$item['id']));?>">Delete</a>
						</td>
					</tr>
				<?php 
						endforeach; 
					endif;
				?>
			</tbody>
		</table>
	</fieldset>
</div>
<script type="text/javascript">
	$(function(){
		$('.date').datepicker({dateFormat: 'yy-mm-dd'});
	});	
</script>
<?php $this->_endblock(); ?>